package com.novellotus.iov.carvice.model;

import com.novellotus.iov.carvice.bean.MqttVehicleBean;
import com.novellotus.iov.carvice.bean.RxCarData;
import com.novellotus.iov.carvice.fragment.CarStatuesFragment;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Rich on 2017/8/28.
 */

public class CarStatuesFragmentModel {

    private CarStatuesFragment context;
    private CarStatuesFragmentModelInterface carStatuesFragmentModelInterface;

    public CarStatuesFragmentModel(CarStatuesFragment context, CarStatuesFragmentModelInterface carStatuesFragmentModelInterface) {
        this.context = context;
        this.carStatuesFragmentModelInterface = carStatuesFragmentModelInterface;
    }



    /**
     * @param alarmBean
     * @return获取报警数据
     */
    public List<String> getAlarmList(RxCarData.RealTimeInfoBean.AlarmBean alarmBean) {
        List<String> alarmList = new ArrayList<>();
        if (alarmBean.getTemp_diff() != 0) {
            alarmList.add("温度差异报警");
        }
        if (alarmBean.getBattery_high_temp() != 0) {
            alarmList.add("电池高温报警");
        }
        if (alarmBean.getPower_battery_pack_overvoltage() != 0) {
            alarmList.add("动力蓄电池包过压报警");
        }
        if (alarmBean.getPower_battery_pack_undervoltage() != 0) {
            alarmList.add("动力蓄电池包欠压报警");
        }
        if (alarmBean.getSoc_low() != 0) {
            alarmList.add("SOC过低报警");
        }
        if (alarmBean.getSoc_hightest() != 0) {
            alarmList.add("SOC过高报警");
        }
        if (alarmBean.getSoc_jump_change() != 0) {
            alarmList.add("SOC跳变报警");
        }
        if (alarmBean.getSingle_battery_undervoltage() != 0) {
            alarmList.add("单体蓄电池欠压报警");
        }
        if (alarmBean.getSingle_battery_overvoltage() != 0) {
            alarmList.add("单体蓄电池过压报警");
        }

        if (alarmBean.getPower_battery_pack_mismatch() != 0) {
            alarmList.add("动力蓄电池包不匹配报警");
        }
        if (alarmBean.getPower_battery_pack_consistency_diff() != 0) {
            alarmList.add("动力蓄电池包一致性差报警");
        }
        if (alarmBean.getInsulation() != 0) {
            alarmList.add("绝缘报警");
        }
        if (alarmBean.getDc_dc_temp() != 0) {
            alarmList.add("DC-DC温度报警");
        }
        if (alarmBean.getBrake_sys() != 0) {
            alarmList.add("制动系统报警");
        }
        if (alarmBean.getDc_dc_status() != 0) {
            alarmList.add(" DC-DC状态报警");
        }

        if (alarmBean.getDc_dc_temp() != 0) {
            alarmList.add("驱动电机控制器温度报警");
        }
        if (alarmBean.getHigh_voltage_lock_status() != 0) {
            alarmList.add("高压互锁状态报警");
        }
        if (alarmBean.getMotor_temp() != 0) {
            alarmList.add("驱动电机温度报警");
        }
        if (alarmBean.getVehicle_energy_unit_type_overcharge() != 0) {
            alarmList.add("车载储能装置类型过充报警");
        }

        return alarmList;
    }

    /**
     * @param alarmBean mqtt获取的报警数据
     * @return
     */
    public List<String> getAlarmList(MqttVehicleBean.AlarmBean alarmBean) {
        List<String> alarmList = new ArrayList<>();
        if (alarmBean.getTemp_diff() != 0) {
            alarmList.add("温度差异报警");
        }
        if (alarmBean.getBattery_high_temp() != 0) {
            alarmList.add("电池高温报警");
        }
        if (alarmBean.getPower_battery_pack_overvoltage() != 0) {
            alarmList.add("动力蓄电池包过压报警");
        }
        if (alarmBean.getPower_battery_pack_undervoltage() != 0) {
            alarmList.add("动力蓄电池包欠压报警");
        }
        if (alarmBean.getSoc_low() != 0) {
            alarmList.add("SOC过低报警");
        }
        if (alarmBean.getSoc_hightest() != 0) {
            alarmList.add("SOC过高报警");
        }
        if (alarmBean.getSoc_jump_change() != 0) {
            alarmList.add("SOC跳变报警");
        }
        if (alarmBean.getSingle_battery_undervoltage() != 0) {
            alarmList.add("单体蓄电池欠压报警");
        }
        if (alarmBean.getSingle_battery_overvoltage() != 0) {
            alarmList.add("单体蓄电池过压报警");
        }

        if (alarmBean.getPower_battery_pack_mismatch() != 0) {
            alarmList.add("动力蓄电池包不匹配报警");
        }
        if (alarmBean.getPower_battery_pack_consistency_diff() != 0) {
            alarmList.add("动力蓄电池包一致性差报警");
        }
        if (alarmBean.getInsulation() != 0) {
            alarmList.add("绝缘报警");
        }
        if (alarmBean.getDc_dc_temp() != 0) {
            alarmList.add("DC-DC温度报警");
        }
        if (alarmBean.getBrake_sys() != 0) {
            alarmList.add("制动系统报警");
        }
        if (alarmBean.getDc_dc_status() != 0) {
            alarmList.add(" DC-DC状态报警");
        }

        if (alarmBean.getDc_dc_temp() != 0) {
            alarmList.add("驱动电机控制器温度报警");
        }
        if (alarmBean.getHigh_voltage_lock_status() != 0) {
            alarmList.add("高压互锁状态报警");
        }
        if (alarmBean.getMotor_temp() != 0) {
            alarmList.add("驱动电机温度报警");
        }
        if (alarmBean.getVehicle_energy_unit_type_overcharge() != 0) {
            alarmList.add("车载储能装置类型过充报警");
        }

        return alarmList;
    }

    public void setInterface(CarStatuesFragmentModelInterface carStatuesFragmentModelInterface) {
        this.carStatuesFragmentModelInterface = carStatuesFragmentModelInterface;
    }

    public interface CarStatuesFragmentModelInterface {
        void setData(RxCarData response);
    }
}
